//
//  HNThreeGoodEvaCell.m
//  优学荟管理系统
//
//  Created by edz on 2017/12/6.
//  Copyright © 2017年 星道三好. All rights reserved.
//

#import "HNThreeGoodEvaCell.h"

@implementation HNThreeGoodEvaCell
{
    __weak IBOutlet UILabel *_Title;
    __weak IBOutlet UILabel *_Num;
    __weak IBOutlet NSLayoutConstraint *_GreenViewWidth;
    __weak IBOutlet UIView *_GrayView;
    __weak IBOutlet UIView *_ColorView;
    
    CGFloat _Trailing;
}

+ (instancetype)ConfigEvaCellWithTitle:(NSString *)Title andNum:(NSInteger)Num andTrailing:(CGFloat)Trailing {
    
    return [[HNThreeGoodEvaCell alloc] initWithTitle:Title andNum:Num andTrailing:Trailing];
}

- (instancetype)initWithTitle:(NSString *)Title andNum:(NSInteger)Num andTrailing:(CGFloat)Trailing  {
    
    self = [[NSBundle mainBundle] loadNibNamed:[HNThreeGoodEvaCell description] owner:nil options:nil][0];
    if (self) {
        
        _Title.text = Title;
        _Num.text = [@(Num) stringValue];
        _Trailing = Trailing;
    }
    return self;
}


- (void)layoutSubviews {
    
    [super layoutSubviews];
    if (_Trailing >= 0.75) {
        
        _ColorView.backgroundColor = ColorRGB(137, 231, 197);
    } else if (_Trailing < 0.75 && _Trailing >= 0.5) {
        
        _ColorView.backgroundColor = ColorRGB(113, 209, 238);
    } else if (_Trailing < 0.5 && _Trailing >= 0.25) {
        
        _ColorView.backgroundColor = ColorRGB(246, 201, 84);
    } else {
        
        _ColorView.backgroundColor = ColorRGB(233, 87, 78);
    }
    _Trailing = _GrayView.frame.size.width * _Trailing;
    _GreenViewWidth.constant = (_Trailing);
    
    
}

@end
